﻿@using Snai.CMS.Manage.Models.BackManage

@model AdminListModel

<div class="search-title">
    <form class="layui-form">
        <div class="layui-form-item">
            <div class="layui-input-inline">
                <input id="userName" name="userName" placeholder="请输入用户名" class="layui-input" autocomplete="off">
            </div>
            <div class="layui-input-inline">
                <select id="roleID" name="roleID">
                    <option value="">请选择角色</option>
                    @foreach (var role in Model.Roles)
                    {
                        <option value="@role.ID">@role.Title</option>
                    }
                </select>
            </div>
            <div class="layui-input-inline">
                <button type="button" id="btnReload" name="btnReload" class="layui-btn">查询</button>
            </div>
        </div>
</form>
</div>

<script type="text/html" id="adminToolbar">
    <div class="layui-btn-container">
        @if (Model.RoleModules.Select(s => new { s.Controller, s.Action }).Contains(new { Controller = "BackManage", Action = "ModifyAdmin" }))
        {
            <button class="layui-btn layui-btn-sm layui-btn-primary" lay-event="add">添加</button>
        }
        @if (Model.RoleModules.Select(s => new { s.Controller, s.Action }).Contains(new { Controller = "BackManage", Action = "UpdateAdminState" }))
        {
            <button class="layui-btn layui-btn-sm" lay-event="enable">启用</button>
            <button class="layui-btn layui-btn-sm layui-btn-warm" lay-event="disable">禁用</button>
        }
        @if (Model.RoleModules.Select(s => new { s.Controller, s.Action }).Contains(new { Controller = "BackManage", Action = "UnlockAdmin" }))
        {
            <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="unlock">解锁</button>
        }
        @if (Model.RoleModules.Select(s => new { s.Controller, s.Action }).Contains(new { Controller = "BackManage", Action = "DeleteAdmin" }))
        {
            <button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="delete">删除</button>
        }
        </div>
</script>

<table id="adminList" lay-filter="adminList"></table>

<script type="text/html" id="stateTpl">
    {{#  if(d.state == 1){ }}
        <p class="font-color-normal">启用</p>
    {{#  } else { }}
        <p class="font-color-danger">禁用</p>
    {{#  } }}
</script>

<script type="text/html" id="lockStateTpl">
    {{#  if(d.lockState == 1){ }}
    <p class="font-color-normal">正常</p>
    {{#  } else { }}
    <p class="font-color-danger">锁定</p>
    {{#  } }}
</script>

<script type='text/html' id='adminBar'>
    @if (Model.RoleModules.Select(s => new { s.Controller, s.Action }).Contains(new { Controller = "BackManage", Action = "ModifyAdmin" }))
    {
        <a class='layui-btn layui-btn-xs' lay-event='edit'>编辑</a>
    }
</script>


@section Scripts{
    <script src="~/js/extensions.js"></script>
    <script src="~/js/utils.js"></script>
    <script src="~/js/adminlist.js"></script>
}

